package ledrpt

class DayInOutYieldController {
    def dynamicQueryService
    def dayInOutYield() {


        params.SYS_QUERY_NAME = 'dayInOutYield'
        def dayInOutYield = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield1'
        def dayInOutYield1 = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield2'
        def dayInOutYield2 = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield3'
        def dayInOutYield3 = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield4'
        def dayInOutYield4 = dynamicQueryService.queryForList(params)
        print(dayInOutYield4)
        params.SYS_QUERY_NAME='packageForm'
        def packageForm=dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME='stepList'
        def stepList=dynamicQueryService.queryForList(params)





        [dayInOutYield:dayInOutYield,dayInOutYield1:dayInOutYield1,dayInOutYield2:dayInOutYield2,dayInOutYield3:dayInOutYield3,dayInOutYield4:dayInOutYield4,

         LOT_ID:params.LOT_ID,SUBSTRATE_ID1:params.SUBSTRATE_ID1,RESERVED1:params.RESERVED1,stepList:stepList,packageForm:packageForm,
         CUSTOMER_ORDER:params.CUSTOMER_ORDER,startTime:params.startTime,STEP_NAME:params.STEP_NAME]
    }
    def exportExcel() {
        def sysQueryName
        def tab = params.timeType// ?:'H'
        //��?
        if(tab.equals('H')) {
            sysQueryName = params.SYS_QUERY_NAME+'HList'
        }else if (tab.equals('D')){
            sysQueryName = params.SYS_QUERY_NAME+'DList'
        }else if (tab.equals('W')){
            sysQueryName = params.SYS_QUERY_NAME+'WList'
        }else if (tab.equals('M')){
            sysQueryName = params.SYS_QUERY_NAME+'MList'
        }else if (tab.equals('Q')){
            sysQueryName = params.SYS_QUERY_NAME+'QList'
        }else if (tab.equals('Y')){
            sysQueryName = params.SYS_QUERY_NAME+'YList'
        }else{
            sysQueryName = params.SYS_QUERY_NAME
        }
        params.startNo = 1
        params.endNo = 99999999999999999
        params.startno = 1
        params.endno = 99999999999999999
        params.SYS_QUERY_NAME = sysQueryName

        def dataList = dynamicQueryService.queryForList(params)

        def tableHeadList =  []
        if(dataList.size()>0){
            tableHeadList =  dataList[0].keySet()
        }
        params.SYS_QUERY_NAME = 'dayInOutYield'
        def dayInOutYield = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield1'
        def dayInOutYield1 = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield2'
        def dayInOutYield2 = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield3'
        def dayInOutYield3 = dynamicQueryService.queryForList(params)
        params.SYS_QUERY_NAME = 'dayInOutYield4'
        def dayInOutYield4 = dynamicQueryService.queryForList(params)

        String filename = new String("${sysQueryName}.xls".getBytes("UTF-8"), "UTF-8");
        response.setContentType('application/vnd.ms-excel;charset=UTF-8')
        response.setHeader('Content-disposition', "attachment;filename=${filename};charset=UTF-8")
        response.setCharacterEncoding("UTF-8");
        render(template: "export${params.EXPORT_CONTENT_NAME}", model: [dataList: dataList,tableHeadList:tableHeadList,
                                                                        dayInOutYield:dayInOutYield,dayInOutYield1:dayInOutYield1,dayInOutYield2:dayInOutYield2,dayInOutYield3:dayInOutYield3,dayInOutYield4:dayInOutYield4])
    }
}
